/**
 * 表单组件样式
 * @description 自定义表单组件的样式定义
 */

.form {
  /* 基础样式 */
  width: 100%;
}

/* 不同尺寸的表单 */
.form.small :global(.ant-form-item) {
  margin-bottom: 16px;
}

.form.small :global(.ant-form-item-label) {
  font-size: 12px;
  line-height: 1.4;
}

.form.small :global(.ant-input),
.form.small :global(.ant-select-selector),
.form.small :global(.ant-picker) {
  font-size: 12px;
}

.form.large :global(.ant-form-item) {
  margin-bottom: 28px;
}

.form.large :global(.ant-form-item-label) {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
}

.form.large :global(.ant-input),
.form.large :global(.ant-select-selector),
.form.large :global(.ant-picker) {
  font-size: 16px;
  padding: 12px 16px;
}

/* 不同布局模式 */
.form.horizontal :global(.ant-form-item-label) {
  text-align: right;
  padding-right: 12px;
}

.form.vertical :global(.ant-form-item-label) {
  text-align: left;
  padding-bottom: 4px;
}

.form.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.form.inline :global(.ant-form-item) {
  margin-bottom: 0;
  margin-right: 0;
}

/* 禁用状态 */
.form.disabled :global(.ant-form-item-label) {
  color: #bfbfbf;
}

.form.disabled :global(.ant-input),
.form.disabled :global(.ant-select-selector),
.form.disabled :global(.ant-picker) {
  background-color: #f5f5f5;
  border-color: #d9d9d9;
  color: #bfbfbf;
  cursor: not-allowed;
}

/* 只读状态 */
.form.readonly :global(.ant-input),
.form.readonly :global(.ant-select-selector),
.form.readonly :global(.ant-picker) {
  background-color: #fafafa;
  border-color: #e8e8e8;
  cursor: default;
}

.form.readonly :global(.ant-input):focus,
.form.readonly :global(.ant-select-selector):focus,
.form.readonly :global(.ant-picker):focus {
  border-color: #e8e8e8;
  box-shadow: none;
}

/* 表单项标签样式 */
.form :global(.ant-form-item-label > label) {
  font-weight: 500;
  color: #262626;
}

.form :global(.ant-form-item-label > label.ant-form-item-required::before) {
  color: #ff4d4f;
  font-size: 14px;
  margin-right: 4px;
}

/* 表单项错误状态 */
.form :global(.ant-form-item-has-error .ant-input),
.form :global(.ant-form-item-has-error .ant-select-selector),
.form :global(.ant-form-item-has-error .ant-picker) {
  border-color: #ff4d4f;
}

.form :global(.ant-form-item-has-error .ant-input:focus),
.form :global(.ant-form-item-has-error .ant-select-selector:focus),
.form :global(.ant-form-item-has-error .ant-picker:focus) {
  border-color: #ff4d4f;
  box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
}

.form :global(.ant-form-item-explain-error) {
  color: #ff4d4f;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

/* 表单项成功状态 */
.form :global(.ant-form-item-has-success .ant-input),
.form :global(.ant-form-item-has-success .ant-select-selector),
.form :global(.ant-form-item-has-success .ant-picker) {
  border-color: #52c41a;
}

/* 表单项警告状态 */
.form :global(.ant-form-item-has-warning .ant-input),
.form :global(.ant-form-item-has-warning .ant-select-selector),
.form :global(.ant-form-item-has-warning .ant-picker) {
  border-color: #faad14;
}

/* 表单项帮助文本 */
.form :global(.ant-form-item-extra) {
  color: #8c8c8c;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .form.horizontal {
    /* 在移动端将水平布局改为垂直布局 */
  }

  .form.horizontal :global(.ant-form-item-label) {
    text-align: left;
    padding-right: 0;
    padding-bottom: 4px;
  }

  .form.horizontal :global(.ant-col) {
    width: 100% !important;
    max-width: 100% !important;
  }

  .form.inline {
    flex-direction: column;
    gap: 0;
  }

  .form.inline :global(.ant-form-item) {
    margin-bottom: 20px;
    width: 100%;
  }

  /* 移动端表单项间距调整 */
  .form :global(.ant-form-item) {
    margin-bottom: 20px;
  }

  .form.small :global(.ant-form-item) {
    margin-bottom: 16px;
  }

  .form.large :global(.ant-form-item) {
    margin-bottom: 24px;
  }
}

/* 深色主题适配 */
[data-theme='dark'] .form :global(.ant-form-item-label > label) {
  color: #d9d9d9;
}

[data-theme='dark'] .form.disabled :global(.ant-form-item-label) {
  color: #595959;
}

[data-theme='dark'] .form.disabled :global(.ant-input),
[data-theme='dark'] .form.disabled :global(.ant-select-selector),
[data-theme='dark'] .form.disabled :global(.ant-picker) {
  background-color: #262626;
  border-color: #434343;
  color: #595959;
}

[data-theme='dark'] .form.readonly :global(.ant-input),
[data-theme='dark'] .form.readonly :global(.ant-select-selector),
[data-theme='dark'] .form.readonly :global(.ant-picker) {
  background-color: #1f1f1f;
  border-color: #303030;
}

[data-theme='dark'] .form :global(.ant-form-item-extra) {
  color: #8c8c8c;
}

/* 表单动画效果 */
.form :global(.ant-form-item) {
  transition: all 0.3s ease;
}

.form :global(.ant-input),
.form :global(.ant-select-selector),
.form :global(.ant-picker) {
  transition: all 0.3s ease;
}

/* 表单验证动画 */
.form :global(.ant-form-item-explain) {
  animation: formErrorSlideIn 0.3s ease-out;
}

@keyframes formErrorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 表单聚焦样式增强 */
.form :global(.ant-input:focus),
.form :global(.ant-select-selector:focus),
.form :global(.ant-picker:focus) {
  border-color: #40a9ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  outline: none;
}

/* 表单项分组样式 */
.form :global(.ant-form-item-control-input-content) {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 表单按钮组样式 */
.form :global(.ant-form-item:last-child) {
  margin-bottom: 0;
}

.form :global(.ant-form-item .ant-btn + .ant-btn) {
  margin-left: 12px;
}

/* 紧凑模式 */
.form.compact :global(.ant-form-item) {
  margin-bottom: 12px;
}

.form.compact :global(.ant-form-item-label) {
  padding-bottom: 2px;
}

/* 宽松模式 */
.form.spacious :global(.ant-form-item) {
  margin-bottom: 32px;
}

.form.spacious :global(.ant-form-item-label) {
  padding-bottom: 8px;
}